package com.bigstar.lolen_e;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import com.google.ads.AdRequest;
import com.google.ads.AdView;

public class ItemMenu extends Activity implements OnClickListener{
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 
        ChampionData.load(this);
        ItemData.load(this);
        Rune.load(this);
        setContentView(R.layout.item_info);
        AdView adview = (AdView)findViewById(R.id.adView);
        AdRequest re = new AdRequest(); 
        adview.loadAd(re);
        Button button = (Button)findViewById(R.id.defence_list);
        button.setOnClickListener(this);
        button = (Button)findViewById(R.id.attack_list);
        button.setOnClickListener(this);
        button = (Button)findViewById(R.id.magic_list);
        button.setOnClickListener(this);
        button = (Button)findViewById(R.id.movement_list);
        button.setOnClickListener(this);
        button = (Button)findViewById(R.id.consumables_list);
        button.setOnClickListener(this);
    }
    
    @Override
    public void onClick(View v) {
    	Intent intent = null;
    	switch(v.getId()){
    	case R.id.defence_list:
    		ItemList.type = 0;
    		intent = new Intent(this, ItemMenu2.class);
    		break;
    	case R.id.attack_list:
    		ItemList.type = 1;
    		intent = new Intent(this, ItemMenu2.class);
    		break;
    	case R.id.magic_list:
    		ItemList.type = 2;
    		intent = new Intent(this, ItemMenu2.class);
    		break;
    	case R.id.movement_list:
    		ItemList.type = 3;
    		ItemList.attr = 0;
    		intent = new Intent(this, ItemList.class);
    		break;
    	case R.id.consumables_list:
    		ItemList.type = 4;
    		ItemList.attr = 0;
    		intent = new Intent(this, ItemList.class);
    		break;
    	}
        if(getIntent().getExtras() != null){
    		intent.putExtra("builder", getIntent().getExtras().getString("builder"));
        }
		this.startActivity(intent);
    }

    @Override
    protected void onResume() {
        ChampionData.load(this);
        ItemData.load(this);
        Rune.load(this);
    	super.onResume();
    	if(Builder.item_select){
        	finish();	
        	Builder.item_select = false;
    	}
    }
}